#pragma once

#include <gofcl_rcu_ctl.h>

typedef struct {
	u8_s hxtal_en : 1;
	u8_s is_hxtal_stable : 1;
	u8_s hxtal_bypass_en : 1;
	u8_s hxtal_monitor_en : 1;
	u8_s : 4;
} rcu_ctl_16_23_expl_s;

_Static_assert(sizeof(rcu_ctl_16_23_expl_s) == 1,
	       "Struct rcu_ctl_16_23_expl_s defined error!");

static inline void rcu_setup_hxtal(rcu_ctl_16_23_expl_s ctl_16_23) {
	union {
		rcu_ctl_16_23_s c;
		rcu_ctl_16_23_expl_s e;
	} ce = {
		.e = ctl_16_23,
	};
	rcu_wreg_ctl_16_23_s(ce.c);
}

static inline rcu_ctl_16_23_expl_s rcu_read_hxtal_setup(void) {
	union {
		rcu_ctl_16_23_s c;
		rcu_ctl_16_23_expl_s e;
	} ce = {
		.c = rcu_rreg_ctl_16_23_s(),
	};
	return ce.e;
}

typedef struct {
	u8_s pll_en : 1;
	u8_s is_pll_stable : 1;
	u8_s pll1_en : 1;
	u8_s is_pll1_stable : 1;
	u8_s pll2_en : 1;
	u8_s is_pll2_stable : 1;
	u8_s : 2;
} rcu_ctl_24_31_expl_s;

_Static_assert(sizeof(rcu_ctl_24_31_expl_s) == 1,
	       "Struct rcu_ctl_24_31_expl_s defined error!");

static inline void rcu_setup_pll(rcu_ctl_24_31_expl_s ctl_24_31) {
	union {
		rcu_ctl_24_31_s c;
		rcu_ctl_24_31_expl_s e;
	} ce = {
		.e = ctl_24_31,
	};
	rcu_wreg_ctl_24_31_s(ce.c);
}

static inline rcu_ctl_24_31_expl_s rcu_read_pll_setup(void) {
	union {
		rcu_ctl_24_31_s c;
		rcu_ctl_24_31_expl_s e;
	} ce = {
		.c = rcu_rreg_ctl_24_31_s(),
	};
	return ce.e;
}